package Creational.Singleton;

/**
 * 类加载到内存就实例化一个单例 JVM保证线程安全  缺点不管用到与否都要加载
 */
public class HungryDemo {

	public static void main(String[] args) {
		for (int i = 0; i < 100; i++) {
			new Thread(() -> System.out.println(Hungary.getInstance().hashCode())).start();
		}
	}
}


class Hungary {
	private Hungary() {}

	private static final Hungary instance = new Hungary();

	public static Hungary getInstance() {
		return instance;
	}
}
